// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import VueResource from 'vue-resource'
import VueRouter from 'vue-router'
import App from './App'
import VueRouters from './routes'

Vue.config.productionTip = false

Vue.use(VueResource)
Vue.use(VueRouter)

// 自定义指令------------全局
// 设置标题颜色
// Vue.directive('rainbow',{
//    bind(el,binding,vnode){
//      el.style.color = "#" + Math.random().toString(16).slice(2,8);
//    }
// })

// 设置列表宽度
Vue.directive('theme',{
  bind(el,binding,vnode){
    if(binding.value == 'wide'){
      el.style.maxWidth = "1260px";
    }else if(binding.value == 'narrow'){
      el.style.maxWidth = "600px";
    }

    if(binding.arg == 'column'){
      el.style.background = '#6677cc';
    }
  }
})

// 自定义过滤器[标题小写改为大写]
// Vue.filter("to-uppercase", function(value){
//   return value.toUpperCase();
// })

// Vue.filter("snippet", function(value){
//   return value.slice(0,100) + "...";
// })

// 创建路由
const router = new VueRouter({
   routes: VueRouters,
   mode: "history"  // 路由打开模式，去掉后面#  http://localhost:8082/#/  可以通过http://localhost:8082 访问
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  components: { App },
  template: '<App/>',
  router: router
})
